{% extends "base.html" %}

{% block conetnt %}
    <section class="content-header">
        <h1>教师端管理系统</h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i>资料管理</a></li>
            <li class="active">资料列表</li>
        </ol>
    </section>
    <section class="content" id="showcontent">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header">
                        <h3 class="box-title">资料列表</h3>
                    </div>
                    {% if messages %}
                        {% for message in messages %}
                            <div class="alert alert-success"> {{ message }}</div>
                        {% endfor %}
                    {% endif %}
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <tbody>
                            <tr>
                                <th>编号</th>
                                <th>名称</th>
                                <th>所属课程</th>
                                <th>文件链接</th>
                                <th>创建日期</th>
                                <th>操作</th>
                            </tr>
                            {% for resource in resources.object_list %}
                                <tr>
                                    <td>{{ resource.id }}</td>
                                    <td>{{ resource.name }}</td>
                                    <td>{{ resource.course.name }}</td>
                                    <td><a href="{{ MEDIA_URL }}{{ resource.downloads }}">{{ resource.downloads.name }}</a></td>
                                    <td>{{ resource.add_time }}</td>
                                    <td>&nbsp;
                                        <a class="label label-danger" href="{% url "teacher:delete_resource" resource.id %}"
                                           >删除</a>
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <ul class="pagination pagination-sm no-margin pull-right">
                            {% if resources.has_previous %}
                                <li><a href="?{{ resources.previous_page_number.querystring }}"
                                       class="prev">上一页</a>
                                </li>
                            {% else %}
                                <li><span class="disabled prev">上一页</span></li>
                            {% endif %}
                            {% for page in resources.pages %}
                                {% if page %}
                                    {% ifequal page resources.number %}
                                        <li><span class="current page">{{ page }}</span>
                                        <li>
                                            {% else %}
                                        <li><a href="?{{ page.querystring }}" class="page">{{ page }}</a></li>
                                    {% endifequal %}
                                {% else %}
                                    ...
                                {% endif %}
                            {% endfor %}
                            {% if resources.has_next %}
                                <li><a href="?{{ resources.next_page_number.querystring }}" class="next">下一页</a></li>
                            {% else %}
                                <li><span class="disabled next">下一页</span></li>
                            {% endif %}
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>
{% endblock %}